﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Reflection;

namespace Manager.CustomerHelper
{
    /// <summary>
    /// 所有模块列表
    /// </summary>
    public enum ModuleType
    {
        None,
        CityAdmin,
        DistrictAdmin,
        CityCenterAdmin,
        DistrictCenterAdmin,
        OrgAdmin,
        SchoolAdmin,
        SchoolManager,
        OrgManager,
        
    }

   

    public class ModuleTypeHelper
    {
        /// <summary>
        /// 字符串转换为ModuleType
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        public static ModuleType String2Module(string text)
        {
            return String2Module(text, false);
        }

        /// <summary>
        /// 字符串转换为ModuleType
        /// </summary>
        /// <param name="text"></param>
        /// <param name="ignoreCase"></param>
        /// <returns></returns>
        public static ModuleType String2Module(string text, bool ignoreCase)
        {
            if (Enum.IsDefined(typeof(ModuleType), text))
            {
                return (ModuleType)Enum.Parse(typeof(ModuleType), text, ignoreCase);
            }
            else
            {
                return ModuleType.None;
            }
        }

        /// <summary>
        /// ModuleType转换为字符串
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static String Module2String(ModuleType type)
        {
            return type.ToString();
        }

        /// <summary>
        /// 获取所有的模块名称列表
        /// </summary>
        /// <returns></returns>
        public static string[] GetAppModules()
        {
            return Enum.GetNames(typeof(ModuleType));
        }


        //private static Dictionary<string, List<string>> _modulePages;

        ///// <summary>
        ///// 获得模块对应的页面列表
        ///// </summary>
        ///// <returns></returns>
        //public static Dictionary<string, List<string>> GetModulePages()
        //{
        //    if (_modulePages != null)
        //    {
        //        return _modulePages;
        //    }

        //    _modulePages = new Dictionary<string, List<string>>();
        //    string[] modules = GetAppModules();
        //    foreach (string module in modules)
        //    {
        //        _modulePages[module] = new List<string>();
        //    }

        //    Assembly asm = Assembly.GetExecutingAssembly();
        //    foreach (Type type in asm.GetTypes())
        //    {
        //        int i = 0;
        //    }
        //    return _modulePages;
        //}

    }
}